From 60a3eafa2b7ea37e994a7a446b9e7223e9234a8e Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Fri, 13 Feb 2009 09:29:52 +0000 Subject: [PATCH] x86 hvm: Allow restore of old images with different segment attribute format. Signed-off-by: Tim Deegan --- xen/arch/x86/hvm/hvm.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index ff531e3ae2..ae4acb3787 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -542,6 +542,22 @@ static int hvm_load_cpu_ctxt(struct domain *d, hvm_domain_context_t *h) return -EINVAL; } + /* Older Xen versions used to save the segment arbytes directly + * from the VMCS on Intel hosts. Detect this and rearrange them + * into the struct segment_register format. */ +#define UNFOLD_ARBYTES(_r) \ + if ( (_r & 0xf000) && !(_r & 0x0f00) ) \ + _r = ((_r & 0xff) | ((_r >> 4) & 0xf00)) + UNFOLD_ARBYTES(ctxt.cs_arbytes); + UNFOLD_ARBYTES(ctxt.ds_arbytes); + UNFOLD_ARBYTES(ctxt.es_arbytes); + UNFOLD_ARBYTES(ctxt.fs_arbytes); + UNFOLD_ARBYTES(ctxt.gs_arbytes); + UNFOLD_ARBYTES(ctxt.ss_arbytes); + UNFOLD_ARBYTES(ctxt.tr_arbytes); + UNFOLD_ARBYTES(ctxt.ldtr_arbytes); +#undef UNFOLD_ARBYTES + /* Architecture-specific vmcs/vmcb bits */ if ( hvm_funcs.load_cpu_ctxt(v, &ctxt) < 0 ) return -EINVAL; -- 2.30.2